-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add export module #1
base: inference
Are you sure you want to change the base?
Conversation
@@ -120,14 +120,18 @@ def forward(self, images, annotations = None): | |||
#jloc_pred_nms = non_maximum_suppression(jloc_pred[0]) | |||
#topK = torch.clamp((jloc_pred_nms > 0.008).count_nonzero(), max=300) | |||
|
|||
juncs_pred, _ = get_junctions(non_maximum_suppression(jloc_pred[0]),joff_pred[0], topk=300, th=0.008) | |||
nms_jloc_pred = non_maximum_suppression(jloc_pred)[0] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the part where I pass the 4 dimensional tensor, and then take out the batch dim after max_pool2d
# idx_junc_to_end_min = torch.min(idx_junc_to_end1,idx_junc_to_end2) | ||
# idx_junc_to_end_max = torch.max(idx_junc_to_end1,idx_junc_to_end2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
torch.min and torch.max signatures are (tensor, dim, keep_dims, ..)
They are used here are torch.min/max(tensor1, tensor2) to do element-wise minimum/maximum operations.
This does not work for onnx, as it sees min and max, and expects the second argument to be an integer, and not a tensor.
The fix is to stack the two tensors together, then take the min/max along the stacked dimension.
wireframe = WireframeGraph(juncs_final,juncs_score,edge_indices,score_final,output.size(3),output.size(2)) | ||
wireframe.rescale(annotations[0]['width'],annotations[0]['height']) | ||
else: | ||
return juncs_final,juncs_score,edge_indices,score_final,output.size(3),output.size(2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
output.size(3) and output.size(2) are not tensors anymore, they probably won't have meaningful data once exported
Adds a module that exports the model to the ONNX framework and executes a test run.
Some minor modifications are made to the model to make it exportable but should not affect the outputs.